package com.example.administrator.myapplication;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;

import com.example.administrator.myapplication.Fragment.gengduofragment;
import com.example.administrator.myapplication.Fragment.shequfragment;
import com.example.administrator.myapplication.Fragment.shipinfragment;
import com.example.administrator.myapplication.Fragment.yingxiongfragment;
import com.example.administrator.myapplication.Fragment.zixunfragment;

public class MainActivity extends AppCompatActivity {
        private FragmentManager manager;
        private RadioButton radioButton;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            radioButton= (RadioButton) findViewById(R.id.ziXun);
            radioButton.setChecked(true);
            manager=getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.add(R.id.containner,new zixunfragment());
            transaction.commit();
        }
        public void change(View view){
            FragmentTransaction transaction = manager.beginTransaction();
            switch (view.getId()){
                case R.id.ziXun:
                    transaction.replace(R.id.containner,new zixunfragment());
                    break;
                case R.id.shiPin:
                    transaction.replace(R.id.containner,new shipinfragment());
                    break;
                case R.id.yingXiong:
                    transaction.replace(R.id.containner,new yingxiongfragment());
                    break;
                case R.id.sheQu:
                    transaction.replace(R.id.containner,new shequfragment());
                    break;
                case R.id.gengDuo:
                    transaction.replace(R.id.containner,new gengduofragment());
                    break;
            }
            transaction.commit();
        }
    }
